﻿@{ ViewBag.Title = "育发知识";

    Layout = "~/Views/Shared/_HTMLLayout.cshtml"; }
<link rel="stylesheet" type="text/css" href='@Url.Content("~/css/sub.css")' />

<script>
    $(document).ready(function () {
        $(window).load(function () {
            $("nav a:nth-child(5)").addClass("onFocus")
        })
    })</script>

<dl class="hair"></dl>


<dl class="knowledge" style="height:650px;">
    <dt><img src='@Url.Content("~/img/title3.png")'></dt>
    <dd id="datalist">
    </dd>
</dl>
<div class="page" id="pageshow">
    <a href='@Url.Content("~/home/GetKnowLedge/1")'>首页</a>
    <a><<</a>
    <a class="nowPage">1</a>
    <a href="">2</a>
    <a href="">3</a>
    <a href="">>></a>
    <a href="">尾页</a>
    <span id="pageTotol">共1页</span>
</div>

<script type="text/javascript">
    $(function () {
        initHair(1);
    });

    function initHair(pagenumber) {
        var itemnumber = 5;
        var type = 4;
        var queryUrl = querybase + '/News/GetPageList' + '?NewsType=' + type + '&PageSize=' + itemnumber + '&PageIndex=' + pagenumber + '&Sort=BaseModifyTime';
    $.ajax({
        type: "GET",
        url: queryUrl,
        data: {},
        datatype: "json",
        success: function (data) {
            var items = data.Data;
            var htm = "";

            if (items != null && items != undefined) {

                for (var i = 0; i < items.length; i++) {

                    var show_date = getDate(items[i].BaseModifyTime);

                    htm += '<a href=\"\/home\/detail\/' + items[i].Id + '\">'
                        + '<div class=\"date\">' + show_date.getDate() + '<span>' + show_date.getFullYear() + '.' + show_date.getMonth() + '</span></div>'
                        + '<div class=\"content\">'
                        + '<h1>' + items[i].NewsTitle + '</h1>'
                        + '<p>' + items[i].NewsTag + '</p>'
                        + '</div>'
                        + '</a >';
                }


                var pageTotal = Math.ceil(data.Total / itemnumber);
                $("#datalist").html(htm);

                $("#pageTotol").html("共" + pageTotal + "页");

                var htmpage = "<a href=\"#\" onclick=\"initHair(1);\">首页<\/a>";

                if (pageTotal == 1) {
                    htmpage += "<a href=\"javascript: return false;\"  style=\"cursor: default;\" style=\"opacity: 0.2\"><<<\/a>"
                        + "<a href=\"javascript: return false;\"  style=\"cursor: default;\" style=\"opacity: 0.2\">>><\/a>";
                }
                else if ((pagenumber - 1) <= 0) {
                    htmpage += "<a href=\"javascript: return false;\"  style=\"cursor: default;\" style=\"opacity: 0.2\"><<<\/a>"
                        + "<a href=\"#\" onclick=\"initHair(" + (pagenumber + 1) + ");\">>><\/a>";
                }
                else if ((pagenumber + 1) >= pageTotal) {
                    htmpage += "<a href=\"#\" onclick=\"initHair(" + (pageTotal - 1) + ");\"><<<\/a>"
                        + "<a href=\"javascript: return false;\"  style=\"cursor: default;\" style=\"opacity: 0.2\">>><\/a>";
                }
                htmpage += "<a href=\"#\" onclick=\"initHair(" + pageTotal + ");\">尾页<\/a>";
                htmpage += "<span>第" + pagenumber + "页<\/span>";
                htmpage += "<span>共" + pageTotal + "页<\/span>";

                $("#pageshow").html(htmpage);
            }
        }
    });
}

</script>